This document explains how to replicate the findings of Stourm and Albuquerque (2024), "Flowers and Bees: Spatial Network Effects in the Adoption of a Sharing-Economy Platform"

===== INPUTS =====
The package contains the following folders and files:

-data/raw_data:			This folder contains the raw data used in the analysis. It contains multiple subfolders. In each subfolder, a .txt file explains the content and source of the file.

-data/data_csv:			This folder contains pre-processed data in CSV format (obtained from processing the contents of data/raw_data). It contains the following elements:
	/centroids.csv:			coordinates of the canton centroids in the Lambert 93 projection.
	/covariates:			a folder that contains the covariates used, which vary at the day/week and/or canton level(s).
	/platformData:			a folder that contains raw platform data.
	/SpatialMatrices:		a folder that contains files that define matrices with a value between each origin canton and each destination canton.
	/timeLocationAggregations:	a folder that contains files defining how cantons are aggregated into higher-level geographic units, and how days and weeks are aggregated to higher-level time units.

-data/data_mat:			This folder contains processed data in MAT format (obtained by loading the contents of data/data_csv in MATLAB). It contains the following elements:
	/covariates:			a folder that contains the covariates used, which vary at the day/week and/or canton level(s).
	/platformData:			a folder that contains raw platform data.
	/SpatialMatrices:		a folder that contains files that define matrices with a value between each origin canton and each destination canton.
	/timeLocationAggregations:	a folder that contains files defining how cantons are aggregated into higher-level geographic units, and how days and weeks are aggregated to higher-level time units.


-Master.sh:		This bash script executes all the code to preprocess data, load data into .mat files for use in MATLAB, estimate models, carry out further analyses, produce exhibits, and compile the paper and web appendix in pdf format. It calls the following sub-scripts:
	a_0_processRawData.sh
	a_1_loadData2Matlab.sh
	a_2_doEDA.sh
	a_3_doModelBasedAnalyses.sh
	a_4_produceExhibits.sh

-a_0_processRawData.sh:		This bash script pre-process raw data to (re-)produce the content of folder data/data_csv.
-a_1_loadData2Matlab.sh:	This bash script loads the pre-processed data (from folder data/data_csv) into Matlab to (re-)produce the content of folder data/data_mat.
-a_2_doEDA.sh:			This bash script performs exploratory data analysis.
-a_3_doModelBasedAnalyses.sh:	This bash script estimates the model and performs all model-based analyses.
-a_4_produceExhibits.sh:	This bash script produces all exhibits and / or copies them to folder exhibits.

-process_raw_data:		This folder contains the code called by a_0_processRawData.sh.

-load_data_2_Matlab:		This folder contains the code called by a_1_loadData2Matlab.sh.

-EDA:				This folder contains the code called by a_2_doEDA.sh.

-code: 				This folder contains MATLAB code called by a_3_doModelBasedAnalyses.sh.

-drawSVGmap.py: 		This Python script is called by Master.sh to draw geographic maps.

-exhibits:			This folder already contains all figures and inputs to create tables. When executing Master.sh, the exhibits are generated again (except for those that require some manual processing, in which case only the inputs to manual processing are produced).

-tex:				This folder contains the LaTeX documents for the main paper and for the web appendix. Both can be compiled to obtain the paper and web appendix in PDF format.

===== HARDWARE, SOFTWARE AND RUN TIME =====
We have executed the code on a MacBook Pro with a M1 chip and 64GB of RAM. As model estimation is particularly demanding (especially for the sub-model of consumer adoptions), we do not recommend launching it on a machine with less than 64GB of RAM.

We have used the following software versions:
	MATLAB R2023b
	Python 3.10.8 (to make maps) along with the following packages:
		cartopy: 0.21.1
		shapely: 2.0.1
		xlrd: 2.0.1
	sqlite3 3.39.5 (used to process the raw data)
	ImageMagick 7.1.0-51 (software to convert maps generated in .svg format into .pdf format)
	pdfcrop 2020/06/06 v1.40 (command line installed as part of Texlive to crop pdf files)
	latexmk 4.77 (command line tool installed as part of TeXLive, useful to compile tex files into pdf at the very end)

The entire process takes about a week to run. The parameter recovery tasks and counterfactual analyses are the most time-consuming part: they may be run in parallel on different machines to speed up the process.

===== OUTPUTS =====
The code (re)produces the following files:
	exhibits/figures/fig2a.pdf
	exhibits/figures/fig2b.pdf
	exhibits/figures/fig3a.pdf
	exhibits/figures/fig3b.pdf
	exhibits/figures_inputs/fig4_legend.pdf
	exhibits/figures_inputs/fig4a1.pdf
	exhibits/figures_inputs/fig4a2.pdf
	exhibits/figures_inputs/fig4b1.pdf
	exhibits/figures_inputs/fig4b2.pdf
	exhibits/figures_inputs/fig4c1.pdf
	exhibits/figures_inputs/fig4c2.pdf
	exhibits/figures/fig5.pdf
	exhibits/figures_inputs/fig7_legend.pdf
	exhibits/figures_inputs/fig7.pdf
	exhibits/figures_inputs/fig8_legend.pdf
	exhibits/figures_inputs/fig8a.pdf
	exhibits/figures_inputs/fig8b.pdf
	exhibits/figures/fig9a.pdf
	exhibits/figures/fig9b.pdf
	exhibits/figures/fig10a.pdf
	exhibits/figures/fig10b.pdf
	exhibits/figures_inputs/fig11_AdvData.csv
	exhibits/figures/figW2a.pdf
	exhibits/figures/figW2b.pdf
	exhibits/tables_inputs/tab3.csv
	exhibits/tables_inputs/tab4_consumerAdoptions.csv
	exhibits/tables_inputs/tab4_providerAdoptions.csv
	exhibits/tables_inputs/tab4_providerExits.csv
	exhibits/tables_inputs/tab4_modelFits.csv
	exhibits/tables_inputs/tab5_a_consumerAdoptions.csv
	exhibits/tables_inputs/tab5_a_providerAdoptions.csv
	exhibits/tables_inputs/tab5_a_providerExits.csv
	exhibits/tables_inputs/tab5_b_consumerAdoptions.csv
	exhibits/tables_inputs/tab5_b_providerAdoptions.csv
	exhibits/tables_inputs/tab5_b_providerExits.csv
	exhibits/tables_inputs/tabW2.csv
	exhibits/tables_inputs/tabW3.csv
	exhibits/tables_inputs/tabW4.csv
	exhibits/tables_inputs/tabW5.csv
	exhibits/tables_inputs/tabW6.csv
	exhibits/tables_inputs/tabW7.csv
	exhibits/tables_inputs/tabW8.csv
	exhibits/tables_inputs/tabW9.csv
	exhibits/tables_inputs/tabW10.csv
	exhibits/tables_inputs/tabW11.csv
	exhibits/tables_inputs/tabW12.csv
	exhibits/tables_inputs/tabW13_consumerAdoptions.csv
	exhibits/tables_inputs/tabW13_providerAdoptions.csv
	exhibits/tables_inputs/tabW13_providerExits.csv
	exhibits/tables_inputs/tabW13_modelFits.csv
	exhibits/tables_inputs/tabW14_consumerAdoptions.csv
	exhibits/tables_inputs/tabW14_providerAdoptions.csv
	exhibits/tables_inputs/tabW14_providerExits.csv
	exhibits/tables_inputs/tabW14_modelFits.csv
	exhibits/tables_inputs/tabW15_consumerAdoptions.csv
	exhibits/tables_inputs/tabW15_providerAdoptions.csv
	exhibits/tables_inputs/tabW15_providerExits.csv
	exhibits/tables_inputs/tabW15_modelFits.csv
	exhibits/tables_inputs/tabW16_model1_consumerAdoptions.csv
	exhibits/tables_inputs/tabW16_model1_modelFits.csv
	exhibits/tables_inputs/tabW16_model2_consumerAdoptions.csv
	exhibits/tables_inputs/tabW16_model2_modelFits.csv
	exhibits/tables_inputs/tabW16_model3_consumerAdoptions.csv
	exhibits/tables_inputs/tabW16_model3_modelFits.csv
	exhibits/tables_inputs/tabW16_model4_consumerAdoptions.csv
	exhibits/tables_inputs/tabW16_model4_modelFits.csv
	exhibits/tables_inputs/tabW16_model5_consumerAdoptions.csv
	exhibits/tables_inputs/tabW16_model5_modelFits.csv
	exhibits/tables_inputs/tabW17.csv
	exhibits/tables_inputs/tabW18a.csv
	exhibits/tables_inputs/tabW18b.csv
	exhibits/tables_inputs/tabW18c.csv
	exhibits/tables_inputs/tabW18_modelFits.csv
	tex/paper.pdf
	tex/web_appendix.pdf

The paper and web appendix are available at tex/paper.pdf and tex/web_appendix.pdf.


===== MANUAL PROCESSINGS =====
Manual work is required to produce some of the exhibits: one needs to copy data from the CSV files into LaTeX code to produce the tables (coded in directly in files paper.tex and web_appendix.tex). For some figures, one needs to combine together some maps, or to do some manipulation with Microsoft Excel. When executing Master.sh, the necessary inputs are produced and stored in figures_inputs.
The figures concerned are:
	-fig4
	-fig7
	-fig8
	-fig11

For each such figure, there is a subfolder within folder exhibits/figures, which contains a Microsoft PowerPoint, Apple Pages or Microsoft Excel that combines the inputs; the corresponding software is then used to generate an image in PDF or PNG format.

As for the tables, they are obtained by copy-pasting values from CSV files, which are produced by Master.sh: these CSV files appear in exhibits/tables_inputs and their names correspond to the table names (e.g. tab4.csv, tab5.csv...).

Some other figures are illustrations that are not produced by the code: they are simply included in folder exhibits/figures. The corresponding figures are the following:
	-fig1
	-fig6
	-figW1

